package com.sgcc.sx.pmos.mobileapp.adapter;

import android.text.TextUtils;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.mobileapp.bean.AccountInfoBean;

public class AccountInfoAdapter extends BaseQuickAdapter<AccountInfoBean.DataDTO, BaseViewHolder> {

    public AccountInfoAdapter() {
        super(R.layout.item_accountinfo);
    }

    public interface BtnClickListener {
        void delete(int position, AccountInfoBean.DataDTO bean);

        void itemClick(int position, AccountInfoBean.DataDTO bean);
    }

    public void setBtnClickListener(BtnClickListener btnClickListener) {
        mBtnClickListener = btnClickListener;
    }

    private BtnClickListener mBtnClickListener;

    @Override
    protected void convert(BaseViewHolder baseViewHolder, AccountInfoBean.DataDTO bean) {
        baseViewHolder.setText(R.id.tv_marketingusername, bean.getMarketingUserName());
        baseViewHolder.setText(R.id.tv_membersnamepointid, bean.getMembersNamepointId());
        baseViewHolder.setText(R.id.tv_pointname, bean.getPointName());
        baseViewHolder.setText(R.id.tv_address, bean.getAddress());
        baseViewHolder.setText(R.id.tv_consno, bean.getConsNo());
        baseViewHolder.getView(R.id.rl_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mBtnClickListener != null) {
                    mBtnClickListener.delete(getItemPosition(bean), bean);
                }
            }
        });

        baseViewHolder.getView(R.id.linner_parent).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mBtnClickListener != null) {
                    mBtnClickListener.itemClick(getItemPosition(bean), bean);
                }
            }
        });
    }

    private String changePowerType(String type) {
        String Type = "国家电网";
        if (TextUtils.equals("1", type)) {
            Type = "国家电网";
        } else if (TextUtils.equals("2", type)) {
            Type = "地方电网";
        } else if (TextUtils.equals("3", type)) {
            Type = "增量配电网";
        }
        return Type;
    }

}
